package com.garden.rocketmq.learn.samples.config.condition;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;

/**
 * Created by Garden on 2021-01-20 16:30
 */
public class FilterConsumerCondition implements Condition {
    @Override
    public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
        Environment environment = conditionContext.getEnvironment();
        String condition = environment.getProperty("rocketmq.consumer.filter.bean");
        if ("true".equals(condition)) {
            return true;
        }
        return false;
    }
}
